cmake_minimum_required(VERSION 3.10)
project(SmartCarExecutor)

# 关键：设置C++17标准（解决GTest编译错误）
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 自动下载并编译GTest（无需手动安装，兼容Windows）
include(FetchContent)
FetchContent_Declare(
    googletest
    URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
    DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
# Windows下防止GTest构建动态库冲突
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# 生成Executor静态库
add_library(executor STATIC executor.cpp)

# 生成单元测试程序
add_executable(executor_test executor_test.cpp)
target_link_libraries(executor_test 
    PRIVATE executor 
    GTest::gtest 
    GTest::gtest_main
)

# 生成客户端交互程序
add_executable(smart_car_client main.cpp)
target_link_libraries(smart_car_client PRIVATE executor)

# 启用测试（支持CTest）
enable_testing()
include(GoogleTest)
gtest_discover_tests(executor_test)